//
//  BaseTabBarController.m
//  XKBaseDemo
//
//  Created by xukai on 2017/10/20.
//  Copyright © 2017年 xukai. All rights reserved.
//

#import "BaseTabBarController.h"
#import "HomeViewController.h"
#import "DiscoverViewController.h"
#import "MeViewController.h"
#import "SearchViewController.h"
#import "BaseNavigationController.h"
#import "UIImage+XKImage.h"

@interface BaseTabBarController ()

@property (nonatomic, strong) HomeViewController *homeVC;
@property (nonatomic, strong) DiscoverViewController *discoverVC;
@property (nonatomic, strong) MeViewController *meVC;
@property (nonatomic, strong) SearchViewController *searchVC;

@end

@implementation BaseTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.tabBar.tintColor = [UIColor orangeColor];
//    self.tabBar.tintColor = [UIColor orangeColor];

    [self addChildVC];
}

-(void) addChildVC
{
    _homeVC = [[HomeViewController alloc] init];
    _discoverVC = [[DiscoverViewController alloc] init];
    _meVC = [[MeViewController alloc] init];
    _searchVC = [[SearchViewController alloc] init];
    
    [self addOneChildVc:_homeVC title:@"Home" img:@"tabBar_homePage_n" selectImg:@"tabBar_homePage_h"];
    [self addOneChildVc:_discoverVC title:@"Discover" img:@"tabBar_map_n" selectImg:@"tabBar_map_h"];
    [self addOneChildVc:_meVC title:@"Me" img:@"tabBar_aboutMe_n" selectImg:@"tabBar_aboutMe_h"];
    [self addOneChildVc:_searchVC title:@"Search" img:@"tabBar_hot_n" selectImg:@"tabBar_hot_h"];
    
}

-(void) addOneChildVc:(UIViewController *) vc title:(NSString *) title img:(NSString *) img selectImg:(NSString *) selectImg
{
    vc.tabBarItem.title = title;
    vc.tabBarItem.image = [UIImage imageWithOriginalName:img];
    vc.tabBarItem.selectedImage = [UIImage imageWithOriginalName:selectImg];
    BaseNavigationController *nav = [[BaseNavigationController alloc] initWithRootViewController:vc];
    
    [self addChildViewController:nav];

}


@end
